package com.ssy.lingxi.purchase.entity.purchaseplan;


import com.ssy.lingxi.purchase.entity.PurchaseNeedPlanDetail;
import com.ssy.lingxi.purchase.entity.converter.JpaJsonToPurchaseNeedPlanDetailConverter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.List;

/**
 * 采购计划明细
 * @author fhj
 * @date 2021/02/25
 * @version 2.0.0
 */
@Data
@Entity
@Table(schema = "public", name = "pu_purchase_plan_detail")
public class PurchasePlanDetail {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "purchase_plan_detail_seq")
    @SequenceGenerator(sequenceName = "pu_purchase_plan_detail_seq", name = "purchase_plan_detail_seq", allocationSize = 1)
    @ApiModelProperty(value = "ID")
    private Long id;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "采购计划ID")
    private Long purchasePlanId;

    @Column(columnDefinition = "varchar(16)")
    @ApiModelProperty(value = "物料编号")
    private String number;

    @Column(columnDefinition = "varchar(128)")
    @ApiModelProperty(value = "物料名称")
    private String name;

    @Column(columnDefinition = "varchar(128)")
    @ApiModelProperty(value = "规格型号")
    private String model;

    @Column(columnDefinition = "varchar(16)")
    @ApiModelProperty(value = "品类")
    private String category;

    @Column(columnDefinition = "varchar(20)")
    @ApiModelProperty(value = "品牌")
    private String brand;

    @Column(columnDefinition = "varchar(16)")
    @ApiModelProperty(value = "单位")
    private String unit;

    @Column(columnDefinition = "numeric")
    @ApiModelProperty(value = "成本价")
    private Double costPrice;

    @Column(columnDefinition = "numeric")
    @ApiModelProperty(value = "采购数量")
    private Double purchaseCount;

    @Column(columnDefinition = "numeric")
    @ApiModelProperty(value = "采购金额")
    private Double purchasePrice;

    /**
     * 物料组
     */
    @Column
    private String goodsGroup;

    @Convert(converter = JpaJsonToPurchaseNeedPlanDetailConverter.class)
    @Column(columnDefinition = "jsonb")
    @ApiModelProperty(value = "采购需求计划明细集合")
    private List<PurchaseNeedPlanDetail> purchaseNeedPlanDetailList;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "创建时间")
    private Long createTime = System.currentTimeMillis();
}
